import service from '@/utils/request'
import {ApiResponse,ListApiResponse} from '@/store/dataType.ts'
export const API_ROLE = {
  // 查询角色列表
  listRole:(query?:any):Promise<ListApiResponse> => {return service.get('/system/role/list',{params:query})},

  // 查询角色详细
  getRole:(roleId:string|number):Promise<ApiResponse> => {return service.get('/system/role/' + roleId)},
  // 添加角色
  addRole:(data:any):Promise<ApiResponse> => {return service.post('/system/role',data)},
  // 修改角色
  updateRole:(data:any):Promise<ApiResponse> => {return service.put('/system/role',data)},

  // 修改角色数据权限
  dataScope:(data:any):Promise<ApiResponse> => {return service.put('/system/role/dataScope',data)},


  // 角色状态修改
  changeRoleStatus:(roleId:string|number, status:string):Promise<ApiResponse> => {
    const data = {
      roleId,
      status
    }
    return service.put('/system/role/changeStatus',data)
  },

  // 删除角色
  delRole:(roleId:string|number):Promise<ApiResponse> => {return service.delete('/system/role/' + roleId)},


  // 查询角色已授权用户列表
  allocatedUserList:(query:any):Promise<ListApiResponse> => {return service.get('/system/role/authUser/allocatedList',{params:query})},


  // 查询角色未授权用户列表
  unallocatedUserList:(query:any):Promise<ListApiResponse> => {return service.get('/system/role/authUser/unallocatedList',{params:query})},


  // 取消用户授权角色
  authUserCancel:(data:any):Promise<ApiResponse> => {return service.put('/system/role/authUser/cancel',data)},


  // 批量取消用户授权角色
  authUserCancelAll:(params:any):Promise<ApiResponse> => {return service.put('/system/role/authUser/cancelAll',null,{params})},


  // 授权用户选择,params 配置项只在 ​GET/DELETE​ 方法中会自动附加到 URL
  //对于 ​PUT/POST​ 方法，Axios 不会自动将 params 转换为查询参数
  authUserSelectAll:(params:any):Promise<ApiResponse> => {
    return service.put('/system/role/authUser/selectAll',null,{params})},


  // 根据角色ID查询部门树结构
  deptTreeSelect:(roleId:string|number):Promise<ApiResponse> => {return service.get('/system/role/deptTree/' + roleId)},


}
